<div class="main-content">
	<!-- #section:basics/content.breadcrumbs -->
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<ul class="breadcrumb"><li>
			<i class="ace-icon fa fa-th-large th-large-icon"></i> 系统管理 <i class="ace-icon fa fa-angle-double-right"></i> 菜单管理 
		</li></ul><!-- /.breadcrumb -->
	</div>

	<!-- /section:basics/content.breadcrumbs -->
	<div class="page-content">
		<!-- #section:settings.box -->
		<div class="ace-settings-container" id="ace-settings-container" style="margin-top:-48px;">
			<div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
				<i class="ace-icon fa fa-cog bigger-150"></i>
			</div>
			<div class="ace-settings-box clearfix" id="ace-settings-box">
				<div class="pull-left width-50">
					<!-- #section:settings.skins -->
					<div class="ace-settings-item">
						<div class="pull-left">
							<select id="skin-colorpicker" class="hide">
								<option data-skin="no-skin" value="#438EB9" <?=!isset($_COOKIE['ace_skin'])||$_COOKIE['ace_skin']!='no-skin'?'selected':''?> >#438EB9</option>
								<option data-skin="skin-1" value="#222A2D" <?=isset($_COOKIE['ace_skin'])&&$_COOKIE['ace_skin']=='skin-1'?'selected':''?> >#222A2D</option>
								<option data-skin="skin-2" value="#C6487E" <?=isset($_COOKIE['ace_skin'])&&$_COOKIE['ace_skin']=='skin-2'?'selected':''?> >#C6487E</option>
								<option data-skin="skin-3" value="#D0D0D0" <?=isset($_COOKIE['ace_skin'])&&$_COOKIE['ace_skin']=='skin-3'?'selected':''?> >#D0D0D0</option>
							</select>
						</div>
						<span>&nbsp;肤色切换</span>
					</div>

					<!-- /section:settings.skins -->

					<!-- #section:settings.navbar -->
					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" />
						<label class="lbl" for="ace-settings-navbar">&nbsp; 固定导航</label>
					</div>

					<!-- /section:settings.navbar -->

					<!-- #section:settings.sidebar -->
					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" />
						<label class="lbl" for="ace-settings-sidebar">&nbsp; 固定菜单栏</label>
					</div>
					<!-- /section:settings.sidebar -->
					
					<!-- #section:settings.container -->
					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" />
						<label class="lbl" for="ace-settings-add-container">&nbsp; 宽窄屏切换</label>
					</div>
					<!-- /section:settings.container -->
				</div><!-- /.pull-left -->

				<div class="pull-left width-50">
					<!-- #section:basics/sidebar.options -->
					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-hover" />
						<label class="lbl" for="ace-settings-hover">&nbsp; 内级栏目切换</label>
					</div>

					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-compact" />
						<label class="lbl" for="ace-settings-compact">&nbsp; 菜单栏切换</label>
					</div>

					<div class="ace-settings-item">
						<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-highlight" />
						<label class="lbl" for="ace-settings-highlight">&nbsp; 当前菜单凸显</label>
					</div>
					<!-- /section:basics/sidebar.options -->
				</div><!-- /.pull-left -->
			</div><!-- /.ace-settings-box -->
		</div><!-- /.ace-settings-container -->

		<!-- /section:settings.box -->
		<div class="page-content-area">
			<div class="row">
				<div class="col-xs-12 col-sm-6">
					<div class="widget-box widget-color-blue2">
						<div class="widget-header"><h4 class="widget-title lighter smaller">后台菜单</h4></div>
						<div class="widget-body">
							<div class="widget-main padding-8">
								<div id="tree1" class="tree tree-selectable">
									<div class="tree-folder" style="display: block;">
										<div class="tree-folder-header">
											<i class="ace-icon tree-minus" onclick="showDown(this)"></i>
											<div class="tree-folder-name">ROOT</div>
											<div class="tree-folder-name pull-right" style="display:none;">
												<a class="blue" href="#" data-rel="tooltip" title="" data-original-title="添加" onclick="addMenu(0,0)">
													<i class="ace-icon fa fa-plus bigger-130"></i>
												</a>
											</div>
										</div>
										<div class="tree-folder-content" style="display: block;">
											<?=menu_tree($this->adminMenu)?>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- /.col -->
			</div><!-- /.row -->
		</div><!-- /.page-content-area -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->
<!-- inline scripts related to this page -->

<div class="bootbox modal fade bootbox-prompt in" tabindex="-1" role="dialog" aria-hidden="false" id="menuForm" style="position:absolute;left:100%;display:block;">
	<div style="background-color: #303030;filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity: 0.7;opacity: 0.7;position: fixed;width: 100%;height: 100%;"></div>
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="bootbox-close-button close" data-dismiss="modal" aria-hidden="true" onclick="animateColse('#menuForm')">×</button>
				<h4 class="modal-title"></h4>
			</div>
			<form class="bootbox-form">
				<div class="modal-body">
					<div class="bootbox-body">
						<input class="form-control" type="text" name="title" placeholder="菜单名称（必填）" data-rel="tooltip" title="菜单名称（必填）">
						<input class="form-control" type="text" name="url" placeholder="菜单路径（必填）" data-rel="tooltip" title="菜单路径（必填）" style="margin-top:10px;">
						<input class="form-control" type="text" name="icon" placeholder="菜单图标（一级菜单必填）" data-rel="tooltip" title="菜单图标（一级菜单必填）" style="margin-top:10px;">
						<textarea class="form-control" name="bewrite" placeholder="描述（选填）" data-rel="tooltip" title="描述（选填）" style="margin-top:10px;"></textarea>
						<input class="form-control" type="text" name="sort" placeholder="数字排序（选填，由小到大，默认9999）" data-rel="tooltip" title="数字排序（选填，由小到大，默认9999）" style="margin-top:10px;">
						状态：<label style="margin-top:10px;"><input name="status" type="radio" value="0" class="ace" checked><span class="lbl"> 禁用</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<label style="margin-top:10px;"><input name="status" type="radio" value="1" class="ace"><span class="lbl"> 正常</span></label><br/>
						所属类：<label style="margin-top:10px;"><input name="isaction" type="radio" value="0" class="ace" checked readonly><span class="lbl"> 菜单</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<label style="margin-top:10px;"><input name="isaction" type="radio" value="1" class="ace" readonly><span class="lbl"> 内页操作</span></label>
						<input type="hidden" name="kid">
						<input type="hidden" name="model">
						<input type="hidden" name="parentid">
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" onclick="animateColse('#menuForm')">取消</button>
					<button type="button" class="btn btn-primary">提交</button>
				</div>
			</form>
		</div>
	</div>
</div>

<script type="text/javascript">
$('.tree-folder-header,.tree-folder-content .tree-item').hover(function(){
	$(this).find('div.tree-folder-name.pull-right').show();
},function(){
	$(this).find('div.tree-folder-name.pull-right').hide();
})
function showDown(obj){
	obj=$(obj);
	if($(obj).hasClass('tree-minus')){
		$(obj).parent().next('div.tree-folder-content').slideToggle();
		$(obj).removeClass('tree-minus').addClass('tree-plus');
	}else{
		$(obj).parent().next('div.tree-folder-content').slideToggle();
		$(obj).removeClass('tree-plus').addClass('tree-minus');
	}
}
function addMenu(parid,model){
	$('#menuForm').animate({left:'0'});
	if(parid=='0'&&model=='0'){$('#menuForm .modal-header h4').html('添加后台菜单');}
	else if(parid!='0'&&model=='0'){$('#menuForm .modal-header h4').html('添加后台子菜单');}
	else if(parid=='0'&&model!='0'){$('#menuForm .modal-header h4').html('添加前台菜单');}
	else if(parid!='0'&&model!='0'){$('#menuForm .modal-header h4').html('添加前台子菜单');}
	$('#menuForm input[type="text"]').val('');$('#menuForm input[name="parentid"]').val(parid);
	$('#menuForm input[name="model"]').val(model);$('#menuForm input[name="kid"]').val(0);
	$('#menuForm input[name="status"]:eq(0),#menuForm input[name="isaction"]:eq(0)').prop('checked',true);
}
function upMenu(kid,model,title,url,sort,status,icon,isaction,bewrite,parid){
	$('#menuForm').animate({left:'0'});
	if(parid=='0'&&model=='0'){$('#menuForm .modal-header h4').html('修改后台菜单');}
	else if(parid!='0'&&model=='0'){$('#menuForm .modal-header h4').html('修改后台子菜单');}
	else if(parid=='0'&&model!='0'){$('#menuForm .modal-header h4').html('修改前台菜单');}
	else if(parid!='0'&&model!='0'){$('#menuForm .modal-header h4').html('修改前台子菜单');}
	$('#menuForm input[name="title"]').val(title);$('#menuForm input[name="model"]').val(model);$('#menuForm input[name="kid"]').val(kid);
	$('#menuForm input[name="url"]').val(url);$('#menuForm input[name="sort"]').val(sort);$('#menuForm input[name="icon"]').val(icon);
	$('#menuForm input[name="parentid"]').val(parid);$('#menuForm input[name="bewrite"]').val(bewrite);
	$('#menuForm input[name="status"]:eq('+status+'),#menuForm input[name="isaction"]:eq('+isaction+')').prop('checked',true);
}
function delMenu(kid){
	if(confirm('确认删除当前菜单及子菜单？删除后将不可恢复！')){
		$.ajax({
			type:'POST',
			url:'<?=$this->url("system/delMenu")?>',
			data:'kid='+kid,
			dataType:'json',
			success:function(r){
				if(r.state==1){
					gritter("gritter-success gritter-light",3000,"操作提示",r.html);
					setTimeout('window.location.reload()',2000);
				}else{
					gritter("gritter-error gritter-light",3000,"操作提示",r.html);
				}
			},
			error:function(){
				gritter("gritter-error gritter-light",3000,"操作提示","网络错误！请联系我方工作人员。");
			}
		});
	}
}
$('#menuForm .btn-primary').click(function(){
	$.ajax({
		type:'POST',
		url:'<?=$this->url("system/upMenu")?>',
		data:$('#menuForm form').serialize(),
		dataType:'json',
		success:function(r){
			if(r.state==1){
				gritter("gritter-success gritter-light",3000,"操作提示",r.html);
				setTimeout('window.location.reload()',3000);
			}else{
				gritter("gritter-error gritter-light",3000,"操作提示",r.html);
			}
		},
		error:function(){
			gritter("gritter-error gritter-light",3000,"操作提示","网络错误！请联系我方工作人员。");
		}
	});
});
</script>